package com.example.service.provider.controller;

import com.example.common.dto.TestDto;
import com.example.common.vo.TestVo;
import com.example.service.provider.service.ServiceProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/service")
public class ServiceProviderController {

    @Autowired
    ServiceProvider serviceProvider;

    @GetMapping("/get/noArg")
    public TestVo noArgGet(){
        return new TestVo();
    }


    @PostMapping("/post/objArg")
    public TestVo objArgPost(@RequestBody TestDto dto){
        TestVo vo = serviceProvider.service(dto);
        return vo;
    }
    @PostMapping(value = "/post/urlArgAndBodyArg/{name}/{age}",consumes = MediaType.APPLICATION_JSON_VALUE)
    public TestVo urlArgAndBodyArgPost(@RequestBody TestDto dto,@PathVariable("name") String name,@PathVariable("age")int age){
        TestVo vo = serviceProvider.service(dto);
        vo.setName(name);
        vo.setAge(age);
        return vo;
    }
    @PostMapping("/post/MultipartFile")
    public TestVo multipartFilePost(MultipartFile file){
        TestVo vo = serviceProvider.service(file);
        return vo;
    }

    @DeleteMapping("/delete/noArg")
    public TestVo noArgDelete(){
        TestVo vo = serviceProvider.service();
        return vo;
    }

    @PutMapping("/put/objArg")
    public TestVo objArgPut(@RequestBody TestDto dto){
        TestVo vo = serviceProvider.service(dto);
        return vo;
    }


}
